<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>layout 管理系统大布局 - Layui</title>
    <link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./layui/css/layui.css">
    <style>
        .index-title {
            color: #009688;
            font-weight: bold;
        }

        .index-user {
            height: 60px;

            padding-left: 40px;
        }

        .index-user span:nth-child(3) {
            height: 60px;
            line-height: 60px;
        }
    </style>

</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="index-title layui-logo">新闻管理系统</div>
            <!-- 头部区域（可配合layui 已有的水平导航） -->
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                    <a href="javascript:;">
                        <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                            class="layui-nav-img toux ">
                        <b class="appUser">***</b>
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="">Your Profile</a></dd>
                        <dd><a href="">Settings</a></dd>
                        <dd><a href="">Sign out</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-more-vertical"></i>
                    </a>
                </li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item index-user">
                        <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                            class="layui-nav-img toux ">
                        <span>欢迎&nbsp;&nbsp;&nbsp;<b class="appUser">***</b></span>
                    </li>
                    <li class="layui-nav-item"><a href="javascript:;">
                            <i class="layui-icon layui-icon-home" style="font-size: 16px;margin-right: 10px;"></i>
                            首页</a></li>
                    <li class="layui-nav-item layui-nav-itemed">
                        <a class="" href="javascript:;">
                            <i class="layui-icon layui-icon-read" style="font-size: 16px;margin-right: 10px;"></i>
                            文章管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="./article/art_cate.html" target="art"> <i class="layui-icon layui-icon-app"
                                        style="font-size: 16px;margin-right: 10px;margin-left: 30px;"></i>文章类别</a></dd>
                            <dd><a href="./article/art_list.html" target="art"><i class="layui-icon layui-icon-app"
                                        style="font-size: 16px;margin-right: 10px;margin-left: 30px;"></i>文章列表</a></dd>
                            <dd><a href="./article/art_pub.html" target="art"><i class="layui-icon layui-icon-app"
                                        style="font-size: 16px;margin-right: 10px;margin-left: 30px;"></i>发布文章</a></dd>

                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;"><i class="layui-icon layui-icon-username"
                                style="font-size: 16px;margin-right: 10px;"></i>个人中心</a>
                        <dl class="layui-nav-child">
                            <dd><a href="./user/user_info.html" target="art"><i class="layui-icon layui-icon-app"
                                        style="font-size: 16px;margin-right: 10px;margin-left: 30px;"></i>基本资料</a></dd>
                            <dd><a href="./user/user_avatar.html" target="art"><i class="layui-icon layui-icon-app"
                                        style="font-size: 16px;margin-right: 10px;margin-left: 30px;"></i>更换头像</a></dd>
                            <dd><a href="./user/user_pwd.html" target="art"><i class="layui-icon layui-icon-app"
                                        style="font-size: 16px;margin-right: 10px;margin-left: 30px;"></i>重置密码</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>

        <div class="layui-body">
            <iframe name="art" src="./article/art_pub.html" width="100%" height="100%" frameborder="0"
                scrolling="on"></iframe>
        </div>

        <div class="layui-footer">
            <!-- 底部固定区域 -->
            底部固定区域
        </div>
    </div>
    <script src="./layui/layui.js"></script>
    <script>
        //JS 
        layui.use(['element', 'layer', 'util'], function () {
            var element = layui.element
                , layer = layui.layer
                , util = layui.util
                , $ = layui.$;

            //头部事件
            util.event('lay-header-event', {
                //左侧菜单事件
                menuLeft: function (othis) {
                    layer.msg('展开左侧菜单的操作', { icon: 0 });
                }
                , menuRight: function () {
                    layer.open({
                        type: 1
                        , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                        , area: ['260px', '100%']
                        , offset: 'rt' //右上角
                        , anim: 5
                        , shadeClose: true
                    });
                }
            });

        });
    </script>
</body>

</html>

<script src="./js/jquery-3.6.1.min.js"></script>
<script>
    $.ajax({
        type: 'get',
        url: '/my/userinfo',
        headers: {
            'Authorization': localStorage.getItem('token')
        },
        success: (res) => {
            if (res.status == 1) {
                return window.location.href = './login.html';
            }

            $('.appUser').text(res.data.nickname ? res.data.nickname : res.data.username);


            if (res.data.user_pic != '' && res.data.user_pic != null) $('.toux').attr('src', res.data.user_pic)



        }
    })
    // $('a[target = "art"]').on('click', function () {
    //     console.log(this.href);
    // })
</script>